Repository navigation
Conversation
… report duplicates (#269)
|
Two more checks, added after opening (rerun at 2d7bead): The Neo4j projector. Level 3 with RTA. I made the issue's reproduction a buildable Maven aggregator (svc-a, svc-b and svc-c, with a The constructor edges move the same way. Declared and RTA edges agree in both builds, and an RTA destination now resolves near its source. The run prints the duplicate warning on stderr and exits 0. Unrelated to this PR: on a GraalVM Enterprise 21 runtime, the RTA overlay fails with |
…g --strict (#269) - Source roots are sorted by path. JavaParser lists them in hash order of their absolute paths, so the fallback copy changed with the checkout location. - Duplicate names are warned about on stderr on every run, and are no longer a degradation: the output keeps every copy, so --strict passes. - Tests: copies with diverged signatures (fail if L1 resolves through root 0's order), the checkout-location case, and a pinned limitation: a found copy's own references resolve in the application-wide order. - FqnIndex.ordered returns a read-only list.
With no copy in the caller's own root, L1 fell back in path order while L2 chose the copy nearest the caller, so their edges could contradict each other. L1 now ranks the other roots by leading path segments shared with the caller's root, then path order. Roots are sorted on the /-separated relative path, the same on every OS.
Closes #269.
When one analysis covers several source roots that each declare the same qualified type name (vendored copies of a shared library across services), every caller bound to one arbitrary copy. Nothing reported it. This PR does both of the issue's fixes.
1. Caller-local resolution
TypeSolvertakes a single parent. That keeps their parse caches from multiplying./-separated relative path, the same on every OS. JavaParser'sProjectRootlists them in hash order of their absolute paths, so on main the copy that won changed with the checkout location.schema.FqnIndex.2. Detection
After L1, if any top-level qualified name is declared in more than one file, one warning goes to stderr on every run, with or without
-v. It gives the count and one example with its files. This is not a degradation: the output keeps every copy, so--strictis unaffected. A consumer that keys types by qualified name can find the duplicates in the symbol table itself; python-sdk does so in codellm-devkit/python-sdk#451.Known limitation
Only the caller's reference picks its own copy. A found copy's own declarations (its supertypes, its methods' return and parameter types) resolve in the application-wide order, so a chained call such as
copy.helper().tag()can reach another root'sHelper. Lifting that needs a parse cache per source root, which multiplies memory on large monorepos. A test pins the current behavior.Verification
DuplicateTypeResolutionTest:com.shared.RunStatsDataBean.CallerAbinds to svc-a's copy andCallerBto svc-b's.lib), so a chained call does not reach one copy at L2 and another at L1.-v,--strictpasses, and an application without duplicates prints nothing.FqnIndexTestcovers nearest-copy selection, ties, lookups with no referrer, and read-only results.DuplicateTypeProjectionTest: extends and import edges in Neo4j reach the referring service's own copy../gradlew test: 664 tests, 0 failures.analysis.jsonat-a 1is byte-identical to main's.-a 1 --strictat the head commit exits 0 with the warning, in 17.5 s at a 1.5 GB peak.-a 1with per-root orders ran in 420 s at a 11.1 GB peak, measured on this PR's first revision. That run included fix(output): stream analysis.json and stdout instead of building one String (#277) #278's streaming fix, without which the output limit fails first. The later revisions change only the order of roots, which costs a sort of the roots per root.With #278 (#277): the two touch separate parts of
CodeAnalyzer.javaand separate test classes, so they merge cleanly in either order.